/*
Copyright (C) 2009  Raymond Jeon
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/


#ifndef __GL_LIB_FILE_H__
#define __GL_LIB_FILE_H__


#include "gl_lib_define.h"


#ifdef _DEBUG //		

#define GlFopen(file, type)			GlFpFopen(file, type,	#file,	__FILE__, __LINE__) 
#define GlFopenForce(file, type)	GlFpFopenForce(file, type,	#file,	__FILE__, __LINE__) 
#define GlFclose(fp)				GlFpFclose(fp,			#fp,	__FILE__, __LINE__) 

#else		

#define GlFopen(file, type)			fopen(file, type) 
#define GlFopenForce(file, type)	GlFpFopenForce(file, type) 
#define GlFclose(fp)				fclose(fp) 

#endif		


#ifdef _DEBUG //		

FILE* GlFpFopen(char *file, const char *type, char *szSourceExp, char *szSourceFile, int iSourceLine);
FILE* GlFpFopenForce(char *file, const char *type, char *szSourceExp, char *szSourceFile, int iSourceLine);
int GlFpFclose(FILE *fp, char *szSourceExp, char *szSourceFile, int iSourceLine);

#else

FILE* GlFpFopenForce(char *file, const char *type);

#endif



BOOL GlFileCreate(char *szFile);

#ifdef _DEBUG
#define GlFileRemove(f)	GlFileRemove_(f,__FILE__,__LINE__)
#define GlFileRename(f1,f2)	GlFileRename_(f1,f2,__FILE__,__LINE__)
BOOL GlFileRemove_(char *szFile, char *file, int line);
BOOL GlFileRename_(char *szFile1, char *szFile2, char *file, int line);
#else
BOOL GlFileRemove(char *szFile);
BOOL GlFileRename(char *szFile1, char *szFile2);
#endif


BOOL GlFileCopy(char *szFile1, char *szFile2);
BOOL GlFileGetStringBuf(IN FILE *fp, OUT char *szBuffer, IN int iMax);
BOOL GlFileGetString(IN char *szFile, OUT char *szBuffer, IN int iMax);
BOOL GlFileSetString(IN char *szFile, IN char *szBuffer);
BOOL GlFileAddNum(IN char *szFile, IN int iNum);
long GlFileGetSize(char *file);
char *GlFileGetName(char *szFile);
void GlFileDup(FILE *fpD, FILE *fpS);

void GlFileJustSlash(char *szFile);
void GlFileValidateName(char *szFileName);
BOOL GlFileValCheck(char *szFile);
BOOL GlFileExist(char* szFile);

BOOL GlFileAddLine(char *szFile, char *szData);
BOOL GlFileRemoveLine(char *szFile, char *szData);

#endif	// __GL_LIB_FILE_H__




